package weekMatch.one_341;

public class LeeCode_03 {
    public static void main(String[] args) {
        System.out.println(addMinimum("aaaabb"));
    }
    private static int addMinimum(String word) {
        int count = 1;
        for (int i = 1; i < word.length(); i++) {
            if (word.charAt(i) == 'a')
                count++;
            else if (word.charAt(i) == 'b' && word.charAt(i - 1) != 'a')
                count++;
            else if (word.charAt(i) == 'c' && word.charAt(i - 1) == 'c')
                count++;
        }
        return count * 3 - word.length();
    }
}
